import java.util.ArrayList;
import java.util.Scanner;
public class Admin{
	static Scanner scan = new Scanner(System.in);
	public Admin(){
	}

	 static Project createProject(ArrayList<User> users){
		ArrayList<User> projectMembers = new ArrayList<>();
		Project project = new Project();
		Scanner scan = new Scanner(System.in);
		
		System.out.println("Enter Project Title/Name: ");
		String projectName = scan.nextLine();
		project.setProjectName(projectName);
		
		
		System.out.println("How many members will you involve in this project? ");
		System.out.println("Qty: ");
		int qty = Integer.parseInt(scan.nextLine());
		
		print(users);
		
		while(qty > projectMembers.size()){
			System.out.println("Enter username: ");
			String name = scan.nextLine();
			projectMembers.add(findMember(users,name));
		}
		
		print(projectMembers);
		
		project.setProjectLeader(Admin.chooseProjectLeader(users));
		return project;
	}
	static void print(ArrayList<User> x){
		for(int c = 0; c < x.size();c++){
			System.out.println(x.get(c).getUserName());
		}
	}
	static User chooseProjectLeader(ArrayList<User> projectMembers){
		String projectLeaderName;
		while(true){
			System.out.println("Enter the name of you desired project leader: ");
			projectLeaderName = scan.nextLine();
			
			for(int c = 0; c < projectMembers.size(); ){
				if(projectLeaderName.equalsIgnoreCase(projectMembers.get(c).getUserName())){
					return projectMembers.get(c);
				} else{
					c++;
				}
			}
			
			System.out.println(projectLeaderName + " does not exist in the group");
		}
	}
	
	static User findMember(ArrayList<User> userlist,String username){
		while(true){
			for(int c = 0; c < userlist.size();){
				if(username.equalsIgnoreCase(userlist.get(c).getUserName())){
					System.out.println("added");
					return userlist.get(c);
				} else {
					c++;
				}
			}
			System.out.print(username + "does not exist");
			return null;
		}
	}
}